package com.ss.android.article.base.feature.video;

import android.content.Context;
import android.view.View;
import android.widget.FrameLayout;
import com.ss.android.article.common.e.VideoControllerSupplierProxy;
import com.ss.android.newmedia.activity.FragmentActivity;

public abstract class BaseVideoActivity extends FragmentActivity implements IVideoControllerContext {
    protected FrameLayout mTopVideoHolder;
    protected IVideoController mVideoController;

    public BaseVideoActivity() {

    }

    public IVideoController getVideoController() {
        if(this.mVideoController == null && this.mTopVideoHolder != null) {
            this.mVideoController = VideoControllerSupplierProxy.getInstance().createVideoController(((Context)this), this.mTopVideoHolder, true);
        }

        return this.mVideoController;
    }

    public void init() {
        super.init();
        if(this.mRootView != null) {
            View v0 = this.mRootView.findViewById(com.ss.android.article.browser.R.id.top_video_holder);
            if((v0 instanceof FrameLayout)) {
                this.mTopVideoHolder = ((FrameLayout)v0);
            }
        }
    }

    public void initVideoView() {
        VideoControllerSupplierProxy.getInstance().getVideoControllerInstance().reset(((Context)this), this.mTopVideoHolder, true, null);
    }

    public boolean isStreamTab() {
        return false;
    }

    public void onPause() {
        super.onPause();
        if(this.mVideoController != null) {
            this.mVideoController.releaseMedia();
        }
    }
}

